package com.grao.waterschool.human.common;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @author limk
 */
@Data
public class PageResult<T> implements Serializable {

    private static final long serialVersionUID = 803820748271008997L;

    @Schema(description = "总记录数")
    private long total;

    @Schema(description = "分页数据")
    private List<T> list;

    @Schema(description = "其他数据")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<Object, Object> map = Collections.emptyMap();

    public PageResult() {
        this.total = 0L;
        this.list = Collections.emptyList();
    }

    public PageResult(long total, List<T> list) {
        this.total = total;
        this.list = list;
    }

    public PageResult(long total, List<T> list, Map<Object, Object> map) {
        this.total = total;
        this.list = list;
        this.map = map;
    }
}
